package com.itheima.mapper.client;

import com.itheima.client.orderpojo.Vo.OrderDetails;
import com.itheima.client.orderpojo.Vo.OrderGetShoppingCartVo;
import com.itheima.client.orderpojo.Vo.OrderHistoryVo;
import com.itheima.client.orderpojo.Vo.OrderUserVo;
import com.itheima.client.orderpojo.dto.OrderDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author wuzhiyong
 */
@Mapper
public interface ClientOrderMapper {

    /**
     * 提交订单
     *
     * @param orderDto orderDto
     * @return 条数
     */
    int insertOrder(OrderDto orderDto);

    /**
     * 提交订单-获取收货人信息
     *
     * @param id id
     * @return OrderUserVo
     */
    OrderUserVo selectByUserId(String id);

    /**
     * 提交订单-获取购物车信息
     *
     * @param userId userId
     * @return List<OrderGetShoppingCartVo>
     */
    List<OrderGetShoppingCartVo> selectShoppingCart(String userId);

    /**
     * 提交订单-获取购物车信息
     *
     * @param orderDetails orderDetails
     * @return 条数
     */
    int insertOrderDetails(OrderDetails orderDetails);

    /**
     * 订单列表
     * @param userId userId
     * @param startIndex startIndex
     * @param pageSize pageSize
     * @return List<OrderHistoryVo>
     */
    List<OrderHistoryVo> selectOrderPage(String userId, Integer startIndex, Integer pageSize);

    /**
     * 订单列表-获取订单总数
     * @param userId userId
     * @return 总条数
     */
    @Select("select count(*)from reggie.admin_order where user_id=#{userId}")
    int selectAll(String userId);
}
